package com.atguigu.config;

import com.atguigu.error.MyInterceptor;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.*;


/**
 * @Author : fanxuanyu
 * @Description : 控制层配置类（controller springmvc）
 * @Date : 2024/4/18
 * @Time : 16:58
 * @Version : 1.0
 */
@Configuration
@ComponentScan({"com.atguigu.controller", "com.atguigu.error"})
@EnableWebMvc
public class WebJavaConfig implements WebMvcConfigurer {

    @Override
    public void configureViewResolvers(ViewResolverRegistry registry) {
        registry.jsp("/WEB-INF/views/",".jsp");
    }

    @Override
    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) {
        configurer.enable();
    }

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new MyInterceptor());
    }
}
